var frisby = require('frisby');

frisby.create('初始化')
  .post('http://192.168.247.88:9090/hub/device/initialize', {
      'device-udid':'092700B6-2E6F-45D7-B55D-AEFACED48DDC',
      'version':'1.0'
    })
  .expectStatus(200)
  .expectJSON({
    'result':{
      "value":String,
      "passcodeTelUpdateTime":String,
      "device":{
            "id":String,
            "company":String,
            "heartbeat-time":String,
            "is-reset":String,
            "ipad-name":String,
            "light-folder-expiration":String,
            "contactphone":String,
            "contactperson":String,
            "ensureEfbdev":String
          },
      "version":{
            "isforce":String,
  		    	"latest":String,
  	    	  "url":String
          },
      "tasks":Array
    }})
  .expectJSON('result.tasks.?', {
      "flight_no":String,
      "long_reg":String,
      "dept_airport":String,
      "arr_airport":String,
      "flightdate":String
    })
.toss();

frisby.create('非法设备')
  .post('http://192.168.247.88:9090/hub/device/initialize', {
      'device-udid':'092700B6-2E6F-45D7-B55D-INVALID-DEVICE',
      'version':'1.0'
    })
  .expectStatus(200)
  .expectJSON({
    'result':{
        "value": 'error',
        "info": '非法设备'
      }})
.toss()

frisby.create('有需要强制更新的版本')
  .post('http://192.168.247.88:9090/hub/device/initialize', {
      'device-udid':'092700B6-2E6F-45D7-B55D-INVALID-DEVICE',
      'version':'1.0'
    })
  .expectStatus(200)
  .expectJSON({
    'result':{
        "value": 'error',
        "info": '有需要强制更新的版本'
      }})
.toss()

frisby.create('设备已作废')
  .post('http://192.168.247.88:9090/hub/device/initialize', {
      'device-udid':'092700B6-2E6F-45D7-B55D-INVALID-DEVICE',
      'version':'1.0'
    })
  .expectStatus(200)
  .expectJSON({'result':{
        "value": 'error',
        "info": '设备已作废'
      }})
.toss()

frisby.create('未设置当前版本')
  .post('http://192.168.247.88:9090/hub/device/initialize', {
      'device-udid':'092700B6-2E6F-45D7-B55D-INVALID-DEVICE',
      'version':'1.0'
    })
  .expectStatus(200)
  .expectJSON({'result':{
        "value": 'error',
        "info": '未设置当前版本'
      }})
.toss()

frisby.create('查无此版本号')
  .post('http://192.168.247.88:9090/hub/device/initialize', {
      'device-udid':'092700B6-2E6F-45D7-B55D-INVALID-DEVICE',
      'version':'1.0'
    })
  .expectStatus(200)
  .expectJSON({'result':{
        "value": 'error',
        "value":'error',
		    "info":'查无此版本号',
		    "isforce":'1',
		    "latest":'1.4.3',
		    "url":'http://mobilehnasis.hnair.com/apps/dl.html'
      }})
.toss()
